package com.sky.mapper;


import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    @AutoFill(OperationType.INSERT)
    @Insert("insert into dish (name, category_id, price, status, description, image, create_time, update_time," +
            " create_user, update_user) values (#{name},#{categoryId},#{price},#{status},#{description},#{image}" +
            ",#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Dish dish);

    List<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where id = #{id}")
    DishDTO getById(Long id);

    void delete(List<Long> ids);

    @Select("select count(*) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @Select("select * from dish where status = 1 and category_id = #{categoryId}")
    List<DishDTO> list(Long categoryId);

//    @Select("select count(*) from dish where status = #{status}")
//    Integer countByStatus(Integer status);
}
